{include file="header" title="YunCMS后台管理系统" keywords="" description=""/}
<div class="content-page">
    <div class="am-container">
        <div class="page-title"><h1 class="am-inline">{$action_name}角色</h1></div>
        <form class="edit-form role-access-form" method="post" data-am-validator>
            <div class="am-form-group input-group">
                <label>角色名称<span>(请填写角色名称)</span></label>
                <div>
                    <input type="text" name="role[role_name]"
                           value="{notempty name='$role'}{$role.role_name}{/notempty}" class="am-form-field"
                           placeholder="请填写角色名称" required>
                    <input type="hidden" name="role[role_id]" value="{notempty name='role'}{$role.role_id}{/notempty}">
                    <input type="submit" class="am-btn am-btn-primary" value="提交">
                </div>
            </div>
            <div class="role-check-access">
                <h3>权限信息</h3>
                <div>
                    {volist name="actions" id="ac"}
                    <div class="role-nav am-panel am-panel-default">
                        <div class="am-panel-hd">
                            <label class="am-checkbox">
                                <input type="checkbox" name="ac[]"
                                       value="{notempty name='ac.href'}{:url($ac.href)}{/notempty}" data-am-ucheck>
                                {$ac.name}
                            </label>
                        </div>
                        <div class="am-panel-bd">
                            {volist name="ac.submenus" id="act"}
                            <div class="node-1">
                                <label class="am-checkbox node-1-title">
                                    <input type="checkbox" name="ac[]"
                                           value="{notempty name='act.href'}{:url($act.href)}{/notempty}"
                                           data-am-ucheck>
                                    {$act.name}
                                </label>
                                {notempty name="act.submenus"}
                                {volist name="act.submenus" id="men"}
                                <div class="node-2">
                                    <label class="am-checkbox node-2-title">
                                        <input type="checkbox" name="ac[]"
                                               value="{notempty name='men.href'}{:url($men.href)}{/notempty}"
                                               data-am-ucheck>
                                        {$men.name}
                                    </label>
                                    {notempty name="men.actives"}
                                    {volist name="men.actives" id="acti"}
                                    <div>
                                        <label class="am-checkbox">
                                            <input type="checkbox" name="ac[]"
                                                   value="{notempty name='acti.href'}{:url($acti.href)}{/notempty}"
                                                   data-am-ucheck>
                                            {$acti.name}
                                        </label>
                                    </div>
                                    {/volist}
                                    {/notempty}
                                </div>
                                {/volist}
                                {/notempty}
                                {notempty name="act.actives"}
                                {volist name="act.actives" id="acti"}
                                <div>
                                    <label class="am-checkbox">
                                        <input type="checkbox" name="ac[]"
                                               value="{notempty name='acti.href'}{:url($acti.href)}{/notempty}"
                                               data-am-ucheck>
                                        {$acti.name}
                                    </label>
                                </div>
                                {/volist}
                                {/notempty}
                            </div>
                            {/volist}
                        </div>
                    </div>
                    {/volist}
                </div>
            </div>
            {:token()}
        </form>
    </div>
</div>
{include file="footer" /}
{notempty name='role'}
<script type="text/javascript">
    var access = {$role.access|json_encode};
    function checkDefaultAccess(url) {
        for (var i in access) {
            if (access[i].access == url) {
                return true;
            }
        }
        return false;
    }
    $(function () {
        $('.am-ucheck-checkbox').each(function () {
            if ($(this).val()) {
                if (checkDefaultAccess($(this).val())) {
                    $(this).uCheck('check');
                    $(this).trigger('change');
                }
            }
        });
    });
</script>
{/notempty}
